<%@ page language="java" contentType="text/html; charset=UTF-8" pageEncoding="UTF-8" %>
<% 
	String context = request.getContextPath(); 
%>
<html>
<head>
    <title>功能角色</title>
    <link rel="stylesheet" type="text/css" href="<%=context %>/Source/lib/ligerUI/skins/ligerui-icons.css" />
<link rel="stylesheet" type="text/css" href="<%=context %>/Source/lib/ligerUI/skins/Aqua/css/ligerui-all.css" />
</head>

<body style="padding: 0;overflow:hidden;">
    <div id="layout1" style="margin: -1px">
        <div id="toolbar"></div>
        <div id="mainGrid" style="margin: -1px; min-width: 480px;"></div>
    </div>
</body>
<script src="<%=context %>/gooflow/jquery.min.js"></script>
<script src="<%=context %>/Source/lib/ligerUI/js/ligerui.all.js"></script>
<script type="text/javascript">
    	var path = '<%=context %>';
        var _path = path+"/bap";
        $(function () {
            $("#layout1").ligerLayout({ leftWidth: 420, allowLeftResize: true, allowLeftCollapse: true, rightWidth: 420, space: 2, heightDiff: -1 });
            //角色列表
            $("#mainGrid").ligerGrid({
                columns: [
                    { display: 'id', name: 'roleId', /* hide: true, */ width: 60},
                    { display: '名称', name: 'roleName', align: 'left',width:220}
                ], url: _path + "/list/json?rnd=" + Math.random(), pageStatMessage: '',
                width: 320, height: '100%', heightDiff: -1,checkbox:true
            });
            toolbar();
        });
        function toolbar() {
            var items = [];
            items.push({type: 'text', text: "&nbsp;&nbsp;&nbsp;<input type='text' id='search_name_like' name='search_name_like' />"});
            items.push({type: 'button', text: "查 询", icon: 'search', click: function () { f_doSearch(); }});
            $("#toolbar").ligerToolBar({
                items: items
            });
            $("#mainGrid").ligerGetGridManager()._onResize();
        }

        //enter事件
        $(document).keydown(function (e) {
            if (e.keyCode == 13) {
                f_doSearch();
            }
        });
        //查询
        function f_doSearch() {
            var manager = $("#mainGrid").ligerGetGridManager();
            manager.set('parms', {search_name_like: $("#search_name_like").val()});
            manager.loadData();
        }
        function f_load() {
            $("#mainGrid").ligerGetGridManager().loadData(true);
        }
        /*
         * 确定选择角色，并组装数据
         * */
        function f_roleJson(){
            var manager = $("#mainGrid").ligerGetGridManager();
            var rows = manager.getCheckedRows();
            var roles = [];
            if (rows && rows.length > 0) {
                $(rows).each(function () {
                    var hostJson = {id:this.roleId,name:this.roleName,code:this.code}
                    roles.push(hostJson);
                });
            }
            return roles;
        }
    </script>
</html>
